package com.itheima.d06_date_sdf;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test {
    public static void main(String[] args) throws ParseException {
        //1.定义string变量，存储时间
        String start = "2020-09-01 10:00:10";
        String end = "2020-09-01 10:10:00";
        String xj="2020-09-01 10:05:00";
        String xp="2020-09-01 10:10:59";

        //2.讲字符串转换为日期时间对象Date
        java.text.SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startDate = sdf.parse( start);
        Date endDate = sdf.parse( end);
        Date xjDate = sdf.parse( xj);
        Date xpDate = sdf.parse( xp);

        //3.
        if (xjDate.after(startDate)&&xpDate.before(endDate)){
            System.out.println("小家秒杀成功");

        }else{
            System.out.println("小家秒杀失败");

        }
        if (xpDate.after(startDate)&&xpDate.before(endDate)){
            System.out.println("小pi 秒杀成功");

        }else{
            System.out.println("小pi 秒杀失败");

        }

    }
}
